import { _decorator, Component, Node } from 'cc';
import AbstractComponent from '../base/AbstractComponent';
import { Label } from 'cc';
import { PD } from '../player/PlayerData';
import { EventConst } from './Common';
import { App } from '../App';
import { showHallWallet } from '../tools/PopuUp';
const { ccclass, property } = _decorator;

@ccclass('CoinNode')
export class CoinNode extends AbstractComponent {

    @property(Label)
    label_coin : Label = null;

    start() {
        App.Event.on(EventConst.UPDATA_USERINFO,this.setIcon, this )

        this.setIcon()
    }

    onBtnAdd() {
        this.playClickAudio()
        showHallWallet(null)
    }

    /**
     * 更新金币
     */
    setIcon() {
        this.label_coin.string = PD.user.coin_str
    }

    protected onDestroy(): void {
        App.Event.off(EventConst.UPDATA_USERINFO,this.setIcon,this)
    }

}

